55#pragma warning(disable : 4996)
96 context.
first = value;
102 uint16_t index = (uint16_t(context.
first) << 8) | uint16_t(context.
second);
116#include "bmfont_defs_generated.hpp"
127 parsers::parse_bmfont_file(gen, err, bmfont_file_context);
132 uint16_t index = (uint16_t(
first) << 8) | uint16_t(
second);
143 if(i != 0 && ch == 0xC3 &&
uint8_t(
string[i + 1]) == 0xA3) {
146 }
else if(ch == 0xA4) {
152 total +=
chars[ch].x_advance * (ch == 0xA3 ? 0.25f : 1.f);
159 glDeleteTextures(1, &
ftexid);
163 if(
auto it =
state.font_collection.bitmap_fonts.find(font_handle); it !=
state.font_collection.bitmap_fonts.end()) {
166 auto fit =
state.font_collection.font_names.find(font_handle);
167 assert(fit !=
state.font_collection.font_names.end());
169 auto sv =
state.to_string_view(fit->second);
171 return std::string(
"garamond_14");
172 if(sv ==
"Main_14_plain")
173 return std::string(
"garamond_14");
174 if(sv ==
"Main_14_grey")
175 return std::string(
"garamond_14_bold");
176 if(sv ==
"Main_14_black")
177 return std::string(
"garamond_14_bold");
178 if(sv ==
"Main_14_red")
179 return std::string(
"garamond_14_bold");
180 if(sv ==
"Main_14_bold")
181 return std::string(
"garamond_14_bold");
182 if(sv ==
"Main_14_orange")
183 return std::string(
"garamond_14_bold");
184 if(sv ==
"Main_14_eu")
185 return std::string(
"garamond_14");
186 if(sv ==
"tahoma_60")
187 return std::string(
"mapfont_56");
188 if(sv ==
"mapfont_56_small")
189 return std::string(
"vic_22_bl");
190 if(sv ==
"ToolTip_Font")
191 return std::string(
"garamond_16");
193 return std::string(
"Arial14");
194 return std::string(sv);
197 auto root = get_root(
state.common_fs);
198 auto gfx_dir = open_directory(root,
NATIVE(
"gfx"));
199 auto font_dir = open_directory(gfx_dir,
NATIVE(
"fonts"));
202 if(!
bool(font_def) || !
bool(font_image)) {
203 auto result =
state.font_collection.bitmap_fonts.insert_or_assign(font_handle,
bm_font());
204 return result.first->second;
206 auto result =
state.font_collection.bitmap_fonts.insert_or_assign(font_handle,
bm_font(
state, *font_def, *font_image));
207 return result.first->second;
ankerl::unordered_dense::map< uint16_t, int32_t > kernings
bool parse_font(sys::state &state, simple_fs::file &f)
float get_string_width(sys::state &state, char const *, uint32_t) const
int get_kerning_pair(char, char) const
std::array< char_descriptor, 256 > chars
#define assert(condition)
native_string win1250_to_native(std::string_view data_in)
native_string get_full_name(directory const &f)
std::string native_to_utf8(native_string_view data_in)
file_contents view_contents(file const &f)
bm_font const & get_bm_font(sys::state &state, uint16_t font_handle)
scenario_building_context & outer_context
bmfont_file_context(scenario_building_context &outer_context, text::bm_font &font)
void height(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void page(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void first(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void xadvance(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void x(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void y(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void xoffset(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void finish(bmfont_file_context &context)
void yoffset(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void amount(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void width(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void lineheight(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void id(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)
void second(association_type, int32_t value, error_handler &err, int32_t line, bmfont_file_context &context)