std::vector<int> Glyphs::Codepoints(std::string fontstack) { std::vector<int> points; mapnik_fontnik::freetype_engine font_engine_; mapnik_fontnik::face_manager_freetype font_manager(font_engine_); mapnik_fontnik::font_set font_set(fontstack); std::stringstream stream(fontstack); std::string face_name; while (std::getline(stream, face_name, ',')) { font_set.add_face_name(Trim(face_name, " \t")); } mapnik_fontnik::face_set_ptr face_set; // This may throw. face_set = font_manager.get_face_set(font_set); for (auto const& face : *face_set) { FT_Face ft_face = face->get_face(); FT_ULong charcode; FT_UInt gindex; charcode = FT_Get_First_Char(ft_face, &gindex); while (gindex != 0) { charcode = FT_Get_Next_Char(ft_face, charcode, &gindex); if (charcode != 0) points.push_back(charcode); } break; } return points; }
void main(void) { font_t ibm_font, italic_font, min_font; int i; /* First, init the font system */ font_init(); /* Load all the fonts that we can */ ibm_font = font_load(font_ibm); /* 96 tiles */ italic_font = font_load(font_italic); /* 93 tiles */ /* Load this one with dk grey background and white foreground */ color(WHITE, DKGREY, SOLID); min_font = font_load(font_min); /* Turn scrolling off (why not?) */ mode(get_mode() | M_NO_SCROLL); /* Print some text! */ /* IBM font */ font_set(ibm_font); printf("Font demo.\n\n"); printf("IBM Font #!?123\n"); /* In italic */ font_set(italic_font); for (i=1; i!=5; i++) { printf("In italics, line %u\n", i); } /* With a minimal, colour changed font */ font_set(min_font); printf("Minimal 36 tile font\n"); /* Done */ font_set(ibm_font); printf("\nDone!"); }
static void conf_change_font_cp() { font_init(); font_set(conf.font_cp); }
void Glyphs::Range(std::string fontstack, std::string range, std::vector<std::uint32_t> chars) { mapnik_fontnik::freetype_engine font_engine_; mapnik_fontnik::face_manager_freetype font_manager(font_engine_); mapnik_fontnik::font_set font_set(fontstack); std::stringstream stream(fontstack); std::string face_name; // TODO: better to split on delim and font_names_.reserve() then add? while (std::getline(stream, face_name, ',')) { font_set.add_face_name(Trim(face_name, " \t")); } mapnik_fontnik::face_set_ptr face_set; // This may throw. face_set = font_manager.get_face_set(font_set); llmr::glyphs::fontstack *mutable_fontstack = glyphs.add_stacks(); mutable_fontstack->set_name(fontstack); mutable_fontstack->set_range(range); const double scale_factor = 1.0; // Set character sizes. double size = 24 * scale_factor; face_set->set_character_sizes(size); for (std::vector<uint32_t>::size_type i = 0; i != chars.size(); i++) { FT_ULong char_code = chars[i]; mapnik_fontnik::glyph_info glyph; for (auto const& face : *face_set) { // Get FreeType face from face_ptr. FT_Face ft_face = face->get_face(); FT_UInt char_index = FT_Get_Char_Index(ft_face, char_code); // Try next font in fontset. if (!char_index) continue; glyph.glyph_index = char_index; face->RenderSDF(glyph, 24, 3, 0.25); // Add glyph to fontstack. llmr::glyphs::glyph *mutable_glyph = mutable_fontstack->add_glyphs(); mutable_glyph->set_id(char_code); mutable_glyph->set_width(glyph.width); mutable_glyph->set_height(glyph.height); mutable_glyph->set_left(glyph.left); mutable_glyph->set_top(glyph.top - glyph.ascender); mutable_glyph->set_advance(glyph.advance); if (glyph.width > 0) { mutable_glyph->set_bitmap(glyph.bitmap); } // Glyph added, continue to next char_code. break; } } }
void main () { UBYTE keys; UBYTE pos, old_pos = 0; UBYTE note, old_note = 0; UBYTE relative_octave = 0; UBYTE absolute_octave; UBYTE waveform = pulse_50; UBYTE mode = 0; UBYTE root = C; SCALE scale[8]; font_t big_font, small_font; font_init (); big_font = font_load (font_ibm); small_font = font_load (font_spect); font_set (big_font); printf (";; Boueux v%s\n", BOUEUX_VERSION); INIT_SOUND; MASTER_VOLUME = OFF; update_waveform (waveform); MASTER_VOLUME = HIGH; build_scale_mode (scale, root, mode); for (;;) { keys = joypad (); pos = scale_position (keys); if (pos) { note = scale[pos - 1] + relative_octave*OCTAVE_LEN; /* Raise by perfect 4th */ if (PRESSED (B)) note += 5; /* a perfect fourth = 5 semitones */ /* Lower by semitone */ if (PRESSED (A)) note -= 1; } /* Change octave */ if (PRESSED (START)) { relative_octave = !relative_octave; printf ("\n;; rel octave +%d\n", relative_octave); WAIT_KEY_UP (START); } if (PRESSED (SELECT)) { /* Change mode */ if (PRESSED (RIGHT)) { mode = (mode + 1) % NUM_MODES; WAIT_KEY_UP (RIGHT); build_scale_mode (scale, root, mode); } /* Change waveform */ if (PRESSED (LEFT)) { WAIT_KEY_UP (LEFT); waveform = (waveform + 1) % NUM_WAVEFORMS; update_waveform (waveform); } /* Increment root note */ if (PRESSED (UP)) { WAIT_KEY_UP (UP); root = (root + 1) % OCTAVE_LEN; build_scale_mode (scale, root, mode); } /* Decrement root note */ if (PRESSED (DOWN)) { WAIT_KEY_UP (DOWN); if (root == 0) root = OCTAVE_LEN - 1; else root = (root - 1) % OCTAVE_LEN; build_scale_mode (scale, root, mode); } continue; } if ((note != old_note) || (pos != old_pos)) { if (pos) /* Note will be played */ { CH1_VOL = HIGH; CH2_VOL = HIGH; play_note (note, waveform); font_set (small_font); printf (note_names[note % OCTAVE_LEN]); absolute_octave = note/OCTAVE_LEN + 3; printf ("%d", absolute_octave); printf (" "); font_set (big_font); } else /* Stop note */ { CH1_VOL = OFF; CH2_VOL = OFF; printf (". "); } } if (waveform == wawa) wawa_update(); old_note = note; old_pos = pos; } }