This file is indexed.

/usr/share/openscenegraph/examples/osgfont/osgfont.cpp is in openscenegraph-examples 3.2.0~rc1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <cstdlib>
#include <sstream>
#include <osg/io_utils>
#include <osg/ArgumentParser>
#include <osg/Geode>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/StateSetManipulator>

void textInfo(osgText::Text* text)
{
    const osgText::Text::TextureGlyphQuadMap& tgqm = text->getTextureGlyphQuadMap();

    const osgText::Text::TextureGlyphQuadMap::const_iterator tgqmi = tgqm.begin();

    const osgText::Text::GlyphQuads& gq = tgqmi->second;

    osgText::String& s = text->getText();

    for(unsigned int i = 0; i < s.size(); i++)
    {
        osg::Vec2 ul = gq.getCoords()[0 + (i * 4)]; // upperLeft
        osg::Vec2 ll = gq.getCoords()[1 + (i * 4)]; // lowerLeft
        osg::Vec2 lr = gq.getCoords()[2 + (i * 4)]; // lowerRight
        osg::Vec2 ur = gq.getCoords()[3 + (i * 4)]; // upperRight

        /*
        osg::Vec3 ul = gq.getTransformedCoords(0)[0 + (i * 4)];
        osg::Vec3 ll = gq.getTransformedCoords(0)[1 + (i * 4)];
        osg::Vec3 lr = gq.getTransformedCoords(0)[2 + (i * 4)];
        osg::Vec3 ur = gq.getTransformedCoords(0)[3 + (i * 4)];
        */

        osg::notify(osg::NOTICE)
            << "'" << static_cast<char>(s[i]) << "':"
            << " width(" << lr.x() - ll.x() << ")"
            << " height(" << ul.y() - ll.y() << ")" << std::endl << "\t"
            << "ul(" << ul << "), "
            << "ll(" << ll << "), "
            << "lr(" << lr << "), "
            << "ur(" << ur << ")"
            << std::endl
        ;
    }
}

osg::Camera* createOrthoCamera(double width, double height)
{
    osg::Camera* camera = new osg::Camera();

    camera->getOrCreateStateSet()->setMode(
        GL_LIGHTING,
        osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF
    );

    osg::Matrix m = osg::Matrix::ortho2D(0.0f, width, 0.0f, height);

    camera->setProjectionMatrix(m);
    camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    camera->setViewMatrix(osg::Matrix::identity());
    camera->setClearMask(GL_DEPTH_BUFFER_BIT);
    camera->setRenderOrder(osg::Camera::POST_RENDER);

    return camera;
}

osgText::Text* createLabel(const std::string& l, const char* f, unsigned int size)
{
    static osg::Vec3 pos(10.0f, 10.0f, 0.0f);

    osgText::Text* label = new osgText::Text();
    osgText::Font* font  = osgText::readFontFile(f);

    label->setFont(font);
    label->setCharacterSize(size);
    label->setFontResolution(size, size);
    label->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
    label->setPosition(pos);
    label->setAlignment(osgText::Text::LEFT_BOTTOM);

    // It seems to be important we do this last to get best results?
    label->setText(l);

    textInfo(label);

    pos.y() += size + 10.0f;

    return label;
}

typedef std::list<unsigned int> Sizes;

int main(int argc, char** argv)
{
    osgViewer::Viewer   viewer;
    osg::ArgumentParser args(&argc, argv);

    // Make sure we have the minimum args...
    if(argc <= 2)
    {
        osg::notify(osg::FATAL) << "usage: " << args[0] << " fontfile size1 [size2 ...]" << std::endl;

        return 1;
    }


    viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
    viewer.addEventHandler(new osgViewer::StatsHandler());
    viewer.addEventHandler(new osgViewer::WindowSizeHandler());

    osg::Group*  group  = new osg::Group();
    osg::Camera* camera = createOrthoCamera(1280.0f, 1024.0f);

    // Create the list of desired sizes.
    Sizes sizes;

    for(int i = 2; i < argc; i++)
    {
        if(!args.isNumber(i)) continue;

        sizes.push_back(std::atoi(args[i]));
    }

    osg::Geode* geode = new osg::Geode();

    // Add all of our osgText drawables.
    for(Sizes::const_iterator i = sizes.begin(); i != sizes.end(); i++)
    {
        std::stringstream ss;

        ss << *i << " 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        geode->addDrawable(createLabel(ss.str(), args[1], *i));
    }

    camera->addChild(geode);

    group->addChild(camera);

    viewer.setSceneData(group);

    return viewer.run();
}