VE - Damage Popup change "FontFace"?

Discussion in 'Javascript/Plugin Support' started by AdamSakuru, Apr 19, 2018.

  1. AdamSakuru

    AdamSakuru [Null_Value] Veteran

    Messages:
    314
    Likes Received:
    169
    First Language:
    English
    Primarily Uses:
    N/A
    https://victorenginescripts.wordpress.com/rpg-maker-mv/damage-popup/
    I'm using Victor's Damage Popup plugin and there's a parameter for "Font Face"

    Code:
    -Popup Fontface
    The parameters 'Fontface' defines the font name for the popup display.
    You can use script codes that returns a string with the fontname se the
    value for it. 
    But I'm not sure how to do this. Would anyone know the right way? By default it's this:
    Code:
    this.standardFontFace()
     
    #1
  2. kovak

    kovak Silverguard Veteran

    Messages:
    1,248
    Likes Received:
    1,552
    Location:
    I'm from the Hu3
    First Language:
    PT - EN
    Primarily Uses:
    RMMV
    this.fontFace = 'font name'

    as far as i know they need to be in .ttf format to work
     
    #2
  3. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,626
    Likes Received:
    1,049
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Not quite, the way Victor set it up, it requires a function (because he uses the eval command on it, it can't just be the name of the font as a simple string).

    This is the default function:
    Code:
    Window_Base.prototype.standardFontFace = function() {
       if ($gameSystem.isChinese()) {
          return 'SimHei, Heiti TC, sans-serif';
       } else if ($gameSystem.isKorean()) {
          return 'Dotum, AppleGothic, sans-serif';
       } else {
          return 'GameFont';
       }
    };
    
    So it stands to reason you could insert this code into the plugin somewhere:
    Code:
    Window_Base.prototype.myFontFace = function() {
       return 'XXXXXXX';
    };
    
    Where XXXXXXX is the font-family defined in your gamefont.css file.

    And then your parameter in the plugin would be:
    Code:
    this.myFontFace()
    
     
    #3
    AdamSakuru likes this.
  4. AdamSakuru

    AdamSakuru [Null_Value] Veteran

    Messages:
    314
    Likes Received:
    169
    First Language:
    English
    Primarily Uses:
    N/A
    I apologize if this is obvious bit I'm unfamiliar with this stuff. How do I set it to a font that is not the game font?
     
    #4
  5. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,279
    Likes Received:
    799
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Assuming you have the font and the permissions (if required) to use it: copy the font file into your project's fonts subfolder, then use Notepad or something to open the gamefont.css file (found in the same folder) and add this:
    Code:
    @font-face {
        font-family: FontLabel;
        src: url("font-name-goes-here.ttf");
    }
    Replace FontLabel with whatever you like, e.g. PopupFont. The font-family label is what's used in the code to refer to this font. As you can see, the actual filename goes in the brackets on the next line. Then for the parameter in Victor's plugin I'd suggest trying this:
    Code:
    String('FontLabel');
    Again, replace FontLabel with whatever you called it in the CSS file. I think this should work around the eval without the need for additional code, though I haven't tested it myself... :kaoswt:


    If you don't have a licence/permission to distribute the font you want to use but it can be expected to be present on the players' systems (e.g. if you want to use Segoe UI on Windows systems), this old thread on the Steam Discussions may be of interest: https://steamcommunity.com/app/363890/discussions/1/1318836262668686748/
     
    #5
  6. AdamSakuru

    AdamSakuru [Null_Value] Veteran

    Messages:
    314
    Likes Received:
    169
    First Language:
    English
    Primarily Uses:
    N/A
    Thanks to the both of you for the help. I got it working.
     
    #6
    caethyril likes this.
  7. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,626
    Likes Received:
    1,049
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @caethyril That's a clever trick, I didn't think of using the String global object to get around the eval!
     
    #7
    caethyril likes this.

Share This Page