0 Favourites

How do I adapt text to my screen and add my own font

  • Hello,

    I'm here today to know how can i adapt my text to my screen, when try my game on Firefox, my texts was good, but on my phone the text is so big. It is possible to adapt the text with a box, or Text-box (I never use it and don't know how) or with event ?

    And my 2nd question is, How do i add my own font on my project, i used a dafont that i had downloaded but when I export my game on my phone, the font used was Arial, so not mine..

    Thanks for replies and if you have some questions, don't hesitate ! Good day !

  • Hi,

    I can only really answer your 2nd question because I'm actually trying to get everything adapted to different screens aswell. Currently I'm trying something that I found in another thread here on the forum. That is, setting the font-size css property of the textbox to "1.5vh" . I have no idea if it works everywhere but it seems like it works on my devices.

    To your 2nd question: I would use web fonts. Here https://fonts.google.com/ you can find many free web fonts. You just have to add the right url (for example this one: "https://fonts.googleapis.com/css?family=Bungee+Inline") to the web font property. If you have no internet connection this won't work though.

    I hope this helps <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Thanks your reply !

    But my game will be an offline game, it is possible to add a .zip with my font in my file for Intel xdk and change some words to use my own font ?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • I don't really know a way of changing the font for offline games. Actually I would be interested in seeing how that works too .

    But maybe this thread contains some valuable information for you. At least there is an explanation on how to import a css font into your game files.

    If that doesn't work, you could try out Sprite Fonts. They will work online and offline .

  • Sprite fonts ? A sprite with only text ? If yes, isnt too loud for the game ?

  • A Sprite Font is an object which contains an image of all characters of your font. Your game can use the image to write text just as the text object does.

    Here is the manual entry: https://www.scirra.com/manual/166/sprite-font

    I found this Sprite Font Generator: sprite-font-generator-v2_t8654

    It should be able to convert the font that you already installed in a Sprite Font. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • So i create this event : "On touch.." set text to Sprite Font : Hi world

    And it will work ?

  • No, you have to add the Sprite Font object just as any other plugin like the Text object into your project first.

    Then you can either use the default font, which is loaded in the Sprite Font, or you can import a Sprite Font just like you import an image to the Sprite object (It is the same editor window). After that you have to set the right character width and height in the object's properties bar. You will get that information from the sprite font generator I found when you create your own sprite fonts.

    When you are finished with these steps you should be able to just write your text in the text property or use the "set Text" action just like you do it with the Text object.

    I hope this helps!

  • Thanks, i'll try tonight, if i've some questions i'll come back here :p

  • Came here to say about sprite font too, it'll work for you.

    Check some tutos on youtube, it's easy and great =P

  • I'm sorry but i don't know how to add my own font in the sprite font, my file is .ttf, it's right ?

  • If you have a specific font (ttf) then, to use sprite font, you'll have to make a sprite font sheet.

    If you don't need fancy effects on the text, just true type font then actually there's no need to sprite font. Check the other method provided by our friend.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)