* Renaming or moving a directory within the known font directories is now
handled correctly. * The path of moved styles is now updated (also when their parent directories are moved). * FontManager::_AddPath() can no longer crash when you leave the _newDirectory parameter set to NULL. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17163 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2006, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -15,9 +15,10 @@
|
|||||||
#include "FontManager.h"
|
#include "FontManager.h"
|
||||||
|
|
||||||
#include <FontPrivate.h>
|
#include <FontPrivate.h>
|
||||||
|
|
||||||
#include FT_CACHE_H
|
#include FT_CACHE_H
|
||||||
|
|
||||||
|
#include <Entry.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32 kInvalidFamilyFlags = ~0UL;
|
const uint32 kInvalidFamilyFlags = ~0UL;
|
||||||
|
|
||||||
@@ -139,7 +140,23 @@ FontStyle::GetHeight(float size, font_height& height) const
|
|||||||
const char*
|
const char*
|
||||||
FontStyle::Path() const
|
FontStyle::Path() const
|
||||||
{
|
{
|
||||||
return fPath.String();
|
return fPath.Path();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Updates the path of the font style in case the style
|
||||||
|
has been moved around.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
FontStyle::UpdatePath(const node_ref& parentNodeRef)
|
||||||
|
{
|
||||||
|
entry_ref ref;
|
||||||
|
ref.device = parentNodeRef.device;
|
||||||
|
ref.directory = parentNodeRef.node;
|
||||||
|
ref.set_name(fPath.Leaf());
|
||||||
|
|
||||||
|
fPath.SetTo(&ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2006, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <ObjectList.h>
|
#include <ObjectList.h>
|
||||||
|
#include <Path.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
@@ -142,6 +143,8 @@ class FontStyle : public ReferenceCounting, public Hashable/*, public BLocker*/
|
|||||||
uint16 PreservedFace(uint16) const;
|
uint16 PreservedFace(uint16) const;
|
||||||
|
|
||||||
const char* Path() const;
|
const char* Path() const;
|
||||||
|
void UpdatePath(const node_ref& parentNodeRef);
|
||||||
|
|
||||||
void GetHeight(float size, font_height &heigth) const;
|
void GetHeight(float size, font_height &heigth) const;
|
||||||
font_direction Direction() const
|
font_direction Direction() const
|
||||||
{ return B_FONT_LEFT_TO_RIGHT; }
|
{ return B_FONT_LEFT_TO_RIGHT; }
|
||||||
@@ -165,7 +168,7 @@ class FontStyle : public ReferenceCounting, public Hashable/*, public BLocker*/
|
|||||||
private:
|
private:
|
||||||
FT_Face fFreeTypeFace;
|
FT_Face fFreeTypeFace;
|
||||||
BString fName;
|
BString fName;
|
||||||
BString fPath;
|
BPath fPath;
|
||||||
node_ref fNodeRef;
|
node_ref fNodeRef;
|
||||||
|
|
||||||
FontFamily* fFamily;
|
FontFamily* fFamily;
|
||||||
|
|||||||
@@ -205,13 +205,32 @@ FontManager::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
if (directory != NULL) {
|
if (directory != NULL) {
|
||||||
// something has been added to our watched font directories
|
// something has been added to our watched font directories
|
||||||
|
|
||||||
|
// test, if the source directory is one of ours as well
|
||||||
|
nodeRef.node = fromNode;
|
||||||
|
font_directory* fromDirectory = _FindDirectory(nodeRef);
|
||||||
|
|
||||||
if (entry.IsDirectory()) {
|
if (entry.IsDirectory()) {
|
||||||
// there is a new directory to watch for us
|
if (fromDirectory == NULL) {
|
||||||
_AddPath(entry);
|
// there is a new directory to watch for us
|
||||||
|
_AddPath(entry);
|
||||||
|
FTRACE("new directory moved in");
|
||||||
|
} else {
|
||||||
|
// A directory from our watched directories has
|
||||||
|
// been renamed or moved within the watched
|
||||||
|
// directories - we only need to update the
|
||||||
|
// path names of the styles in that directory
|
||||||
|
nodeRef.node = node;
|
||||||
|
directory = _FindDirectory(nodeRef);
|
||||||
|
if (directory != NULL) {
|
||||||
|
for (int32 i = 0; i < directory->styles.CountItems(); i++) {
|
||||||
|
FontStyle* style = directory->styles.ItemAt(i);
|
||||||
|
style->UpdatePath(directory->directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FTRACE("directory renamed");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// test, if the source directory is one of ours as well
|
|
||||||
nodeRef.node = fromNode;
|
|
||||||
font_directory* fromDirectory = _FindDirectory(nodeRef);
|
|
||||||
if (fromDirectory != NULL) {
|
if (fromDirectory != NULL) {
|
||||||
// find style in source and move it to the target
|
// find style in source and move it to the target
|
||||||
nodeRef.node = node;
|
nodeRef.node = node;
|
||||||
@@ -219,6 +238,7 @@ FontManager::MessageReceived(BMessage* message)
|
|||||||
if (style != NULL) {
|
if (style != NULL) {
|
||||||
fromDirectory->styles.RemoveItem(style, false);
|
fromDirectory->styles.RemoveItem(style, false);
|
||||||
directory->styles.AddItem(style);
|
directory->styles.AddItem(style);
|
||||||
|
style->UpdatePath(directory->directory);
|
||||||
}
|
}
|
||||||
FTRACE(("font moved"));
|
FTRACE(("font moved"));
|
||||||
} else {
|
} else {
|
||||||
@@ -598,7 +618,8 @@ FontManager::_AddPath(BEntry& entry, font_directory** _newDirectory)
|
|||||||
|
|
||||||
font_directory* directory = _FindDirectory(nodeRef);
|
font_directory* directory = _FindDirectory(nodeRef);
|
||||||
if (directory != NULL) {
|
if (directory != NULL) {
|
||||||
*_newDirectory = directory;
|
if (_newDirectory)
|
||||||
|
*_newDirectory = directory;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user