Add system font lookup for mac/windows

This changes the font plugin from using a font file to using a specific
installed system font, which is searched for on each specific system and
associated with the font file.  It now uses a font property instead of a
path property, and font size has been removed because the font property
now handles that.

When the module is first loaded, it will build up a list of system fonts
in order to be usable by Freetype.  It was quite painful to program this
because font files can contain multiple localized versions of their face
names, and then there was the issue where windows likes to mangle
custom style types to the font name.  Regardless, it all seems to have
worked out pretty well.

Minor issues:
- Truetype/Opentype fonts sometimes do not automatically have
  italic and/or bold styles available, it seems that the system applies
  transformations manually in those cases.  We don't do this yet,
  however, so right now a user might select a font with italic/bold
  only to discover that italic/bold doesn't always work.  Not entirely
  sure what to do about this yet.  There's probably a freetype function
  to do something like that somehow,

This also requires that iconv be used for non-windows systems to be able
to look up localized font names within font files.  Windows will use
the win32 API and code page IDs to translate font names.
This commit is contained in:
jp9000
2014-08-17 07:13:05 -07:00
parent 1a5eca34db
commit 7f0ae838d7
10 changed files with 891 additions and 54 deletions

View File

@@ -0,0 +1,56 @@
# Once done these will be defined:
#
# LIBICONV_FOUND
# LIBICONV_INCLUDE_DIRS
# LIBICONV_LIBRARIES
#
# For use in OBS:
#
# ICONV_INCLUDE_DIR
#
if(LIBICONV_INCLUDE_DIRS AND LIBICONV_LIBRARIES)
set(LIBICONV_FOUND TRUE)
else()
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_ICONV QUIET iconv)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_lib_suffix 64)
else()
set(_lib_suffix 32)
endif()
set(ICONV_PATH_ARCH IConvPath${_lib_suffix})
find_path(ICONV_INCLUDE_DIR
NAMES iconv.h
HINTS
${_ICONV_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/additional_install_files/include"
"$ENV{obsAdditionalInstallFiles}/include"
ENV IConvPath
ENV ${ICONV_PATH_ARCH}
PATHS
/usr/include /usr/local/include /opt/local/include /sw/include)
find_library(ICONV_LIB
NAMES ${_ICONV_LIBRARIES} iconv libiconv
HINTS
${_ICONV_LIBRARY_DIRS}
"${ICONV_INCLUDE_DIR}/../lib"
"${ICONV_INCLUDE_DIR}/../lib${_lib_suffix}"
"${ICONV_INCLUDE_DIR}/../libs${_lib_suffix}"
"${ICONV_INCLUDE_DIR}/lib"
"${ICONV_INCLUDE_DIR}/lib${_lib_suffix}"
PATHS
/usr/lib /usr/local/lib /opt/local/lib /sw/lib)
set(LIBICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR} CACHE PATH "iconv include dir")
set(LIBICONV_LIBRARIES ${ICONV_LIB} CACHE STRING "iconv libraries")
find_package_handle_standard_args(Libiconv DEFAULT_MSG ICONV_LIB ICONV_INCLUDE_DIR)
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIB)
endif()