Vertical align with Created TTF Font

24 views
Skip to first unread message

Kandy Bitxenio

unread,
May 10, 2019, 12:35:37 PM5/10/19
to CodenameOne Discussions
Hi
on Android (in simulator or in IOS work fine) when used on a Label a created TTF Font (from a file), do not vertical align the icon with the font, the font are on top. When I use a native Font works fine. 

Please Help.

Shai Almog

unread,
May 11, 2019, 12:48:46 AM5/11/19
to CodenameOne Discussions
Hi,
fonts are pretty hard to get to 100% as the kerning is pretty different natively. If you have a test case which includes the actual TTF file please file an issue and we'll try to reproduce it.

Kandy Bitxenio

unread,
May 11, 2019, 10:40:13 AM5/11/19
to CodenameOne Discussions
Hi Shai, thank for your response

This is my test case, as you can see, on IOS and Simulador the Valign is center on the Label and on the Picker, but on Android is align on Top, this success in all components:


My form code:

package test.kandy;

import com.codename1.ui.Display;
import com.codename1.ui.Font;
import com.codename1.ui.FontImage;
import com.codename1.ui.Form;
import com.codename1.ui.Label;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.ui.plaf.Style;
import com.codename1.ui.spinner.Picker;

public class ShaiForm extends Form {

private Form previous;
public ShaiForm() {
    setLayout(new BoxLayout(BoxLayout.Y_AXIS));

int fontSize = Display.getInstance().convertToPixels(3);
Font appFont = Font.createTrueTypeFont("Suisse Int'l", "Suisse Int'l.ttf" ).derive(fontSize, Font.STYLE_PLAIN);;

FontImage fntImage = FontImage.createFixed("\uE161", FontImage.getMaterialDesignFont(), 0x0, 100, 100);
Label labelCustomTTF =  new Label ("custom TTF");
Style labelStyle = labelCustomTTF.getAllStyles();
labelStyle.setFont(appFont);
labelCustomTTF.setIcon(fntImage);
Label labelNative =  new Label ("native Font");
labelNative.setIcon(fntImage);
Picker stringPickerCustom = new Picker();
Style pickerStyle = stringPickerCustom.getAllStyles();
pickerStyle.setFont(appFont);
stringPickerCustom.setType(Display.PICKER_TYPE_STRINGS);
stringPickerCustom.setStrings("custom TTF Font");
stringPickerCustom.setText("custom TTF Font");
Picker stringPickerNative = new Picker();
stringPickerNative.setType(Display.PICKER_TYPE_STRINGS);
stringPickerNative.setStrings("native Font");
stringPickerNative.setText("native Font");
add(labelCustomTTF);
add(labelNative);
add(stringPickerCustom);
add(stringPickerNative);
}
public void show() {
        previous = Display.getInstance().getCurrent();
        super.show();
}
public void goBack(){
        previous.showBack();
}
}
 

and this is the result:

On Simulador:

simulador.png




On Android:

Screenshot_20190511-162643.jpg



On IOS:

ios.jpg


Best Regards Kandy

Kandy Bitxenio

unread,
May 11, 2019, 10:46:37 AM5/11/19
to CodenameOne Discussions
I attached the files
ios.jpg
Screenshot_20190511-162643.jpg
simulador.png
ShaiForm.java

Kandy Bitxenio

unread,
May 11, 2019, 11:05:52 AM5/11/19
to CodenameOne Discussions
And the font file.
Suisse Int'l.ttf

Shai Almog

unread,
May 11, 2019, 11:08:14 PM5/11/19
to CodenameOne Discussions
Thanks, but the issue tracker is here: http://github.com/codenameone/CodenameOne/issues/new

In the group or stack overflow it just gets lost.
Reply all
Reply to author
Forward
0 new messages