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

FreeType Font Extension Fixes #1288

Open
wants to merge 11 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@RobertBColton
Copy link
Member

RobertBColton commented Jun 24, 2018

I implemented the ability to find fonts by short names like "Arial" or "Times New Roman" using platform-provided methods. FreeType does not have any sort of abstraction for this and neither does SDL.

The GameMaker manual does specify that the function font_add should accept short names, and not just a full file path to a TTF font file. I use a very simple heuristic to decide what to do. When the provided font name has the suffix .ttf, then I do not bother trying to resolve the name at all and allow the file path to fall through.
https://docs.yoyogames.com/source/dadiospice/002_reference/game%20assets/fonts/font_add.html

However, I did try testing this in GMSv1.4.1804 and got the following error message whether I added the ttf extension or not:

FreeType :: unable to find font file Arial

It worked in GM8 however and so did this messed up code:

font1 = font_add("HGfffArialYG", 120, true, true, 0, 255);

There were no errors and the font was big, bold, and italic.

  • Win32: I use Win32's facilities for CreateFont and SelectObject with GetFontData to do the mapping of logical fonts to physical ones.
  • Xlib: I don't know if it works, but I am using an X protocol for enumerating the fonts.
  • Cocoa: I haven't even tried anything yet.

I also changed the font rendering to be 96 dpi to match LateralGM plugin changes I made.
enigma-dev/lgmplugin#65
I extended the same test from that pull request to compare IDE fonts with engine fonts.
Download: ttf-font-dpi-test.zip

Current Master (has 72 dpi)

Master TTF with 150 dpi desktopMaster TTF with 100 dpi desktop

This pull request (has 96 dpi)

PR TTF with 150 dpi desktopPR TTF with 100 dpi desktop

@codecov

This comment has been minimized.

Copy link

codecov bot commented Jun 24, 2018

Codecov Report

Merging #1288 into master will increase coverage by 0.44%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1288      +/-   ##
==========================================
+ Coverage   16.74%   17.18%   +0.44%     
==========================================
  Files         164      164              
  Lines       17095    17099       +4     
==========================================
+ Hits         2862     2939      +77     
+ Misses      14233    14160      -73
Impacted Files Coverage Δ
...Asystem/SHELL/Universal_System/instance_system.cpp 53.19% <0%> (+2.12%) ⬆️
ENIGMAsystem/SHELL/Platforms/General/PFwindow.cpp 34.06% <0%> (+3.29%) ⬆️
ENIGMAsystem/SHELL/Universal_System/var4.cpp 20.38% <0%> (+4.14%) ⬆️
ENIGMAsystem/SHELL/Universal_System/roomsystem.cpp 27.71% <0%> (+5.03%) ⬆️
...system/SHELL/Graphics_Systems/OpenGL1/GLscreen.cpp 59.15% <0%> (+9.85%) ⬆️
...system/SHELL/Graphics_Systems/General/GSscreen.cpp 53.22% <0%> (+15.72%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 950036a...ecf093a. Read the comment docs.

@RobertBColton RobertBColton changed the title Font DPI Fixes and Emake Fonts FreeType Font Extension Fixes Jul 7, 2018

@RobertBColton RobertBColton force-pushed the ttf-dpi-fix branch from 01d5fd3 to 1c051bf Jul 8, 2018

@enigma-dev enigma-dev deleted a comment from EnigmaBot Jul 8, 2018

requestedFont.lfItalic = italic;
requestedFont.lfCharSet = DEFAULT_CHARSET;
strncpy(requestedFont.lfFaceName, name.c_str(), name.length() < LF_FACESIZE ? name.length() + 1 : (LF_FACESIZE - 1));
if (name.length() >= LF_FACESIZE) requestedFont.lfFaceName[LF_FACESIZE - 1] = '\0';

This comment has been minimized.

@RobertBColton

RobertBColton Jul 8, 2018

Member

@JoshDreamland please check my string copy logic here when you get a chance. Thanks.

@RobertBColton RobertBColton force-pushed the ttf-dpi-fix branch from 1c051bf to 01d05a7 Jul 8, 2018

@RobertBColton RobertBColton force-pushed the ttf-dpi-fix branch from 69fb834 to 62284ec Nov 12, 2018

@enigma-dev enigma-dev deleted a comment from EnigmaBot Nov 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment