MCPcopy Create free account
hub / github.com/SFML/SFML / main

Function main

examples/text/Text.cpp:636–844  ·  view source on GitHub ↗

/////////////////////////////////////////////////////// Entry point of application \return Application exit code ///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

634///
635////////////////////////////////////////////////////////////
636int main()
637{
638 sf::RenderWindow window(sf::VideoMode({windowWidth, 800u}), "SFML Text", sf::Style::Titlebar | sf::Style::Close);
639 window.setVerticalSyncEnabled(true);
640
641 const sf::Font font(resourcesDir() / "tuffy.ttf");
642 sf::Text instructions(font,
643 "F1: Toggle text bounding box\nF2: Toggle glyph bounding box\nF3: Toggle cursor\nF4: Cycle "
644 "pre-processing (None, Color, Outline, Italicize, Embolden)\nLeft/Right "
645 "Arrow: Move cursor and glyph bounding box\nMouse Press: Set cursor and glyph bounding box "
646 "position",
647 14u);
648 instructions.setPosition({10.0f, 10.0f});
649
650 std::vector<DemoText> demoTexts;
651
652 // Reserve space to make sure the objects don't get moved
653 demoTexts.reserve(64);
654
655 // clang-format off
656 demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Hello. How are you? I hope you're having a great day!");
657 demoTexts.emplace_back("NotoSerifArmenian-Regular.ttf", u8"Բարև։ Ինչպե՞ս ես։ Հուսով եմ՝ լավ օր ես անցկացնում։");
658 demoTexts.emplace_back("NotoSerifGeorgian-Regular.ttf", u8"გამარჯობა. როგორ ხარ? იმედია, კარგად გაატარე დღე!");
659 demoTexts.emplace_back("NotoNaskhArabic-Regular.ttf", u8"مرحباً، كيف حالك؟ أتمنى أن يكون يومك سعيداً!");
660 demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Hallo. Wie geht es dir? Ich hoffe, du hast einen schönen Tag!");
661 demoTexts.emplace_back("NotoSerifDevanagari-Regular.ttf", u8"नमस्ते। आप कैसे हैं? आशा है आपका दिन अच्छा गुजर रहा होगा!");
662 demoTexts.emplace_back("NotoSerifHebrew-Regular.ttf", u8"שלום. מה שלומך? מקווה שיש לך יום נהדר!");
663 demoTexts.emplace_back("NotoSerifJP-Regular.subset.ttf", u8"こんにちは。お元気ですか?素敵な一日をお過ごしください!");
664 demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Γεια σας. Τι κάνετε; Ελπίζω να έχετε μια υπέροχη μέρα!");
665 demoTexts.emplace_back("NotoSerifKhmer-Regular.ttf", u8"ជំរាបសួរ។ សុខសប្បាយជាទេ? សង្ឃឹមថាអ្នកមានថ្ងៃដ៏អស្ចារ្យ!");
666 demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Hola. ¿Cómo estás? ¡Que tengas un buen día!");
667 demoTexts.emplace_back("NotoSerifKR-Regular.subset.ttf", u8"안녕하세요. 잘 지내시죠? 좋은 하루 보내시길 바랍니다!");
668 demoTexts.emplace_back("NotoSerifMyanmar-Regular.ttf", u8"မင်္ဂလာပါ။ နေကောင်းလား? ကောင်းသောနေ့ကို ပိုင်ဆိုင်နိုင်မည်ဟု မျှော်လင့်ပါသည်။");
669 demoTexts.emplace_back("NotoSerifTamil-Regular.ttf", u8"வணக்கம். எப்படி இருக்கீங்க? இந்த நாள் உங்களுக்கு ரொம்ப நல்லா அமைய வாழ்த்துக்கள்!");
670 demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Здравствуйте. Как поживаете? Надеюсь, у вас отличный день!");
671 demoTexts.emplace_back("NotoSerifTC-Regular.subset.ttf", u8"你好。你好嗎?祝你今天過得愉快!");
672 demoTexts.emplace_back("NotoSerifThai-Regular.ttf", u8"สวัสดี สบายดีไหม หวังว่าคุณคงมีวันดีๆ นะ!");
673 demoTexts.emplace_back("NotoSerifTibetan-Regular.ttf", u8"བདེ་མོ། ཁྱོད་བདེ་མོ? ཁྱེད་རང་ལ་ཉིན་མོ་ཡག་པོ་ཞིག་ཡོང་བའི་རེ་བ་ཡོད།");
674 demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Bonjour. Comment allez-vous ? J'espère que vous passez une bonne journée !");
675 demoTexts.emplace_back("NotoSerifEthiopic-Regular.ttf", u8"ሀሎ። ስላም፧ ጥሩ ቀን እንዳለህ ተስፋ አድርግ!");
676
677 auto& ligatureText = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"ligatures:\nflowers\nmuffins\nwaffles\nstuff");
678 auto& normalText = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Normal/Bold/Italic");
679 auto& boldText = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Normal/Bold/Italic");
680 auto& italicText = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Normal/Bold/Italic");
681 auto& zalgoText = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Z̴̢̧͕̱͍͖̱̙̲̳͉̘̐̒͜a̴̲̖̖̖͈͉̪͎̜̽̓̀̀̒͌l̸̰͙̳̗͎͙̼͓̭̥͖̾̀̅̏͐̾͊̃͂̾ͅg̷̡̢͚̗͎̰̦͔̰̬͍̖̩̺̞͕̓̃̇ö̴̜̳̼̘̗͖͍̻͎͓̣̮̝̯͉̞́̄̉̀̄͆̈́͛̐̂̾͐̓̄");
682 auto& tabText = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Tab: >\t<");
683 auto& rainboxText = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Rainbow Text!");
684 auto& bidiText = demoTexts.emplace_back("NotoNaskhArabic-Regular.ttf", u8"Aligned multi-line\nنص ثنائي الاتجاه باستخدام مكتبة SFML الإصدار " + sfmlVersionString + u8".\nالأرقام: 0123456789");
685 auto& leftAligned = demoTexts.emplace_back("NotoNaskhArabic-Regular.ttf", u8"Left-Aligned\nText\nنص محاذي");
686 auto& centered = demoTexts.emplace_back("NotoNaskhArabic-Regular.ttf", u8"Center-Aligned\nText\nنص محاذي");
687 auto& rightAligned = demoTexts.emplace_back("NotoNaskhArabic-Regular.ttf", u8"Right-Aligned\nText\nنص محاذي");
688 auto& horizontalStrikethrough = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Strikethrough");
689 auto& horizontalUnderlined = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Underlined");
690 auto& verticalKorean = demoTexts.emplace_back("NotoSerifKR-Regular.subset.ttf", u8"누워서 떡 먹기");
691 auto& verticalJapanese = demoTexts.emplace_back("NotoSerifJP-Regular.subset.ttf", u8"七転び八起き");
692 auto& verticalChinese = demoTexts.emplace_back("NotoSerifTC-Regular.subset.ttf", u8"一字值千金");
693 auto& topToBottomText = demoTexts.emplace_back("NotoSerif-Regular.ttf", u8"Down Text");

Callers

nothing calls this directly

Calls 15

colorTextDirectionMethod · 0.80
isOpenMethod · 0.80
updateGlyphBoxMethod · 0.80
updateCursorPositionMethod · 0.80
cyclePreProcessingMethod · 0.80
handleMousePressMethod · 0.80
mapPixelToCoordsMethod · 0.80
updateRainbowTextMethod · 0.80
drawBoundingBoxMethod · 0.80
drawGlyphBoxMethod · 0.80
drawTextMethod · 0.80
drawCursorMethod · 0.80

Tested by

no test coverage detected