freetype otf bug?

freetype otf bug?

Postby yujinfu » Sun May 31, 2015 3:10 pm

Hi , I use freetype extension to read NotoSansHans-Regular.otf file which is the main font file in android 5.0 ,
however the weird problem is some character didn't show but a box like the picture show below。

my code is:

package com.me.test;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;

public class FreetypeOtfTest implements ApplicationListener{

Stage stage;
FreeTypeFontGenerator generator;
BitmapFont bitmapFont;
@Override
public void create() {
generator = new FreeTypeFontGenerator(Gdx.files.internal("font/NotoSansHans-Regular.otf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.characters = "你好ha";
parameter.borderColor = Color.GREEN;
parameter.borderWidth = 0.5f;
parameter.size = 40;
parameter.genMipMaps = true;
parameter.kerning = true;
parameter.color = Color.YELLOW;
parameter.magFilter = TextureFilter.Linear;
parameter.minFilter = TextureFilter.Linear;
bitmapFont = generator.generateFont(parameter);

stage = new Stage();
Label label = new Label("你好haha", new Label.LabelStyle(bitmapFont, null));
label.setPosition(100,100);
stage.addActor(label);
}

@Override
public void resize(int width, int height) {

}

@Override
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

stage.act();
stage.draw();

}

@Override
public void pause() {


}

@Override
public void resume() {


}

@Override
public void dispose() {

bitmapFont.dispose();
generator.dispose();
stage.dispose();
}

}

and the NotoSansHans-Regular.otf is which I extract from android 5.0 's font file.

Please help me find out the quesion , thanks very much.
Attachments
QQ截图20150531230735.png
QQ截图20150531230735.png (3.82 KiB) Viewed 16369 times
yujinfu
 
Posts: 27
Joined: Mon Apr 14, 2014 1:57 pm

Return to Newton

Who is online

Users browsing this forum: No registered users and 1 guest