Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scaling custom fonts #1762

Closed
MaBecker opened this issue Feb 24, 2020 · 5 comments
Closed

scaling custom fonts #1762

MaBecker opened this issue Feb 24, 2020 · 5 comments

Comments

@MaBecker
Copy link
Contributor

There is a conversation with sample coding and output.

http://forum.espruino.com/conversations/344013/

@MaBecker
Copy link
Contributor Author

MaBecker commented Feb 25, 2020

GIST: http://microco.sm/out/RC5Kh

Graphics.prototype.setFontHN7x17 = function() {
  var fHN7x17 = require('Storage').read('fHN7x17');
  var wHN7x17 = require('Storage').read('wHN7x17');
  this.setFontCustom(fHN7x17, 32, wHN7x17, 17);
};

// set custom font
g.setFontHN7x17();
g.getFonts();
/* output
=[
  "4x6",
  "6x8",
  "Vector",
  "HN7x17"
 ]
*/

look's like it is not possible at the moment to scale them

g.setFont( "HN7x17",2);
/* output
Uncaught Error: Unknown font "HN7x17"
 at line 1 col 22
g.setFont( "HN7x17",2);
                     ^
*/

@MaBecker
Copy link
Contributor Author

Great. Now locales can be used that are covered by those fonts!

@MaBecker
Copy link
Contributor Author

Just tested with a Bangle.js and version 2v04.360

  VERSION: "2v04.360",
  GIT_COMMIT: "97258a6aa",

look's like there are some more changes needed to get this working

@MaBecker MaBecker reopened this Feb 25, 2020
@MaBecker
Copy link
Contributor Author

MaBecker commented Feb 25, 2020

Just checked the test sample code.

test_graphics_fonts.js

var font = atob("/4H/AAD/AACPmfEAgZH/APAQ/wDxmY8A/5GfAICA/wD/kf8A8ZH/AA==");
Graphics.prototype.setFontTest = function() {
  this.setFontCustom(font, "0".charCodeAt(0), 4, 8);
}

test fails for fonts with font and width

require("FontHaxorNarrow7x17").add(Graphics);

g.getFonts();
/*
=[
  "4x6",
  "6x8",
  "Vector",
  "HaxorNarrow7x17"
 ]
*/
g.setFont("HaxorNarrow7x17",2);
/*
Uncaught Error: Unknown font "HaxorNarrow7x17"
 at line 1 col 30
g.setFont("HaxorNarrow7x17",2)
                             ^
*/

hope this helps.

@MaBecker
Copy link
Contributor Author

Works perfekt - Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant